package com.neusoft.neuhealth.config;


import com.neusoft.neuhealth.interceptor.JWTInterceptor;
import com.neusoft.neuhealth.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class JwtInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private RedisService redisService;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JWTInterceptor(redisService))
                .addPathPatterns("/**")//拦截所有请求
                .excludePathPatterns("/user/login",
                    "/common/code/request",
                    "/common/code/email",
                    "/common/code/findPassword",
                    // 排除 Swagger UI 相关路径
                    "/swagger-ui/**",
                    "/swagger-ui.html",
                    "/v3/api-docs/**",
                    "/swagger-resources/**",
                    "/webjars/**",
                    "/doc.html",  // 如果你使用了 knife4j 的增强文档
                    "/favicon.ico");//排除哪些请求
    }
}